from forum.models import *
from django.contrib import admin
from django.contrib import databrowse

class DrawingInline(admin.TabularInline):
    model = DbDrawing
    extra = 2

    fieldsets = [
        [
            None, 
            {'fields':['drawing_number'], 'classes':['collapse']}
        ]
    ]

class PicturesInline(admin.TabularInline):
    model = DbPicture
    extra = 2

class FlowInline(admin.TabularInline):
    model = DbFlow
    extra = 2

class MechInline(admin.TabularInline):
    model = DbMechanical

class ElecInline(admin.TabularInline):
    model = DbElectrical

class IandCInline(admin.TabularInline):
    model = DbIandC

class DbCompAdmin(admin.ModelAdmin):
    actions_on_top = True
    list_display = ('unique_id', 'system_name','system_number', 'item_name')
    list_filter = ['system_name', 'building_number', 'is_critical']
    search_fields = ['system_name', 'system_number', 'unique_id', \
        'item_name', 'building_number', 'location', 'is_critical', \
        'additional_identifiers']

    inlines = [DrawingInline, PicturesInline, FlowInline, MechInline, \
               ElecInline, IandCInline]

admin.site.register(DbComponent, DbCompAdmin)
databrowse.site.register(DbComponent)
databrowse.site.register(DbDrawing)
databrowse.site.register(DbPicture)
databrowse.site.register(DbFlow)
databrowse.site.register(DbMechanical)
databrowse.site.register(DbElectrical)
databrowse.site.register(DbIandC)

